<template>
  <div class="top" style="display: flex; align-items: center">
    <p class="left" style="
        width: 8px;
        height: 25px;
        background-color: #f6d39c;
        margin-right: 10px;
        border-radius: 3px;
      "></p>
    <p style="color: white; font-size: 22px; font-weight: 600">{{ $t('消息公告') }} </p>
  </div>
  <div class="box1" style="display: flex; margin-top: 30px">
  </div>
  <div class="box2">
    <div class="inner inner2">
      {{ $t('公告名称') }}:     
      <el-input v-model="form.keyword" :placeholder="$t('公告名称')" />
    </div>
    <div class="inner inner5">
      <div style="
          height: 33px;
          border-radius: 5px;
          background-color: #f6d39c;
         
          cursor: pointer;
          margin-right: 10px;
          display: inline-block;
           padding-left: 5px;
            padding-right: 5px;
            padding-top: 5px;
            box-sizing: border-box;
        " @click="select">
        <el-icon style="font-size: 16px; margin-right: 5px">
          <Search />
        </el-icon>
        <span>{{ $t('查询') }} </span>
      </div>
    </div>
  </div>
  <div class="box3">
    <el-table :data="tableData" width="90%"
      style="font-size: 14px;margin-top: 20px;background-color: #282d37;overflow-x: auto;"
      :header-cell-style="{ background: '#282d37', height: '30px' }">
      <el-table-column prop="name" :label="$t('公告标题')" min-width="200" fixed />
      <el-table-column prop="id" label="ID" width="80" v-if="0 == 1" />
      <el-table-column prop="content" :label="$t('公告内容')"  min-width="500" />
      <el-table-column prop="time_str" :label="$t('发布时间')"  min-width="250" sortable />
      <el-table-column fixed="right" :label="$t('操作栏')" width="120">
        <template #default="{ row }">
          <div style="
          width: 80px;
          height: 28px;
          border-radius: 5px;
          background-color: #f6d39c;
          margin-right: 10px;
          cursor: pointer;
          display: flex;
          align-items: center;
          justify-content: center;
         /*  display: inline-block;
           padding-left: 5px;
            padding-right: 5px;
            padding-top: 2px;
            box-sizing: border-box; */
        " @click="openDetail(row.id)" class="bt">
            <el-icon style="font-size: 14px; margin-right: 5px ;color:black">
              <View />
            </el-icon>
            <span style="font-size: 13px; color:black">{{ $t('详情') }} </span>
          </div>
        </template>
      </el-table-column>
    </el-table>
    <div class="block" style="margin-top: 20px;">
      <el-pagination v-model:current-page="form.page" background layout="prev, pager, next" :total="pageTotal" :default-page-size="15" @current-change="handlePageChange"/>
    </div>
  </div>
  <!-- 详情弹出框 -->
  <el-dialog v-model="dialog" title="Tips" width="800px" draggable style="background-color: #272b37;">
    <template #header="{ close, titleId, titleClass }">
      <div class="my-header">
        <p style="color:white;">{{ $t('公告详情') }}</p>
      </div>
    </template>
    <div style="color: #fff;">
      <h2>{{ detail.name }}</h2>
      <p style="margin: 10px 0;">{{ detail.time_str }}</p>
      <div v-html="detail.content"></div>
    </div>
  </el-dialog>
</template>

<script>
import {
  HomeFilled,
  Promotion,
  Pointer,
  Edit,
  Search,
  Plus,
} from "@element-plus/icons-vue";
import {
  noticeListApi,
  noticeDetailApi
} from '@/api/index'
export default {
  data() {
    return {
      pageTotal:'',
      dialog: false,
      detail: '',
      form: {
        keyword: '',
        page: ''
      },
      input: '',
      tableData: [
      ],
    };
  },
  methods: {
    handlePageChange(){
      this.getNoticeList()
    },
    // 查询
    select() {
      this.getNoticeList()
    },
    // 获取消息公告列表
    getNoticeList() {
      noticeListApi(this.form).then(res => {
        this.pageTotal = res.data.total
        this.tableData = res.data.data
      })
    },
    // 获取消息公告详情
    openDetail(id) {
      const token = localStorage.getItem('token')
      noticeDetailApi({ token, id }).then(res => {
        this.dialog = true
        this.detail = res.data
      })
    },
  },
  components: {},
  mounted() {
    this.getNoticeList()
  }
};
</script>

<style lang="scss" scoped>
:deep(.el-progress-bar__outer) {
  background-color: rgba(255, 255, 255, 0.4);
  /* lightgray, but transparent */
}

/* 进度条颜色 我需要的是渐变色 */
:deep(.el-progress-bar__inner) {
  background-color: white;
  //background: linear-gradient(90deg, #FEC015 0%, #FE8B25 100%);
}

.box1:hover {
  cursor: pointer;
}

.custom-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  //gap: 10px;

  color: white;
}

.topbox {
  width: 100%;
  height: 21px;
  display: flex;
  font-size: 13px;

  // justify-content: space-around;
  .small {
    width: 152px;
    // background-color: pink;
  }

  .small2 {
    width: 152px;
    // background-color: pink;
  }
}

.chart-wrapper {
  width: 100%;
  /* 确保内部图表容器充满el-col */
}

.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  /*   .github-corner {
    position: absolute;
    top: 0px;
    border: 0;
    right: 0;
  } */

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

.box2 {
  display: flex;
  align-items: center;
  color: white;

  :deep(.el-input__wrapper) {
    background-color: black;
    height: 32px;
    box-shadow: none;
  }

  .inner {
    margin-right: 10px;
  }

  .inner2 {
    .el-input {
      width: 220px;
    }
  }

  .inner3 {
    align-items: center;
    display: flex;
  }

  .inner4 {
    align-items: center;
    display: flex;


    .demo-date-picker {
      display: flex;
      width: 100%;
      padding: 0;
      flex-wrap: wrap;
    }

    .demo-date-picker .block {
      padding: 30px 0;
      text-align: center;
      border-right: solid 1px var(--el-border-color);
      flex: 1;
    }

    .demo-date-picker .block:last-child {
      border-right: none;
    }

    .demo-date-picker .demonstration {
      display: block;
      color: var(--el-text-color-secondary);
      font-size: 14px;
      margin-bottom: 20px;
    }
  }

  .inner5 {
    color: #303133;
  }
}

.box3 {
  :deep(.el-table thead) {
    color: white;
  }

  :deep(.el-table td) {
    border-bottom: 3px solid black;
  }

  :deep(.el-table__body-wrapper tr td) {
    background-color: #2d303d;
    color: white;
  }

  :deep(.el-table thead) {
    color: #fff;
  }

  :deep(.el-pagination__total) {
    color: #fff !important;
  }

  :deep(.el-pagination__jump) {
    color: #fff !important;
  }

  :deep(.el-pager li) {
    color: #fff !important;
  }

  :deep(.el-input__inner) {
    color: #fff !important;
  }
}

:deep(.el-pagination button) {
  background-color: black;
  color: white;
}

:deep(.el-pager li) {
  background-color: black;
  // color:white;

}

:deep(.el-input__wrapper) {
  background-color: black;
  box-shadow: none;
}

:deep(.el-input__inner) {
  color: #fff;
}
// 分页器
:deep(.el-pagination) {
  .el-pager li {
    background-color: #000;
  }
}
:deep(.el-pagination.is-background .btn-next){
  background-color: #000;
}
:deep(.el-pagination.is-background .btn-prev){
  background-color: #000;
}
:deep(.el-pagination.is-background .el-pager li.is-active){
  background-color: #999;
}
</style>
